package com.espirit.eap.manager;

public class ModelDirector {
	ModelBuilder modelBuilder;
	public ModelDirector(ModelBuilder modelBuilder){
		this.modelBuilder = modelBuilder;
	}
	/*
	 * 初始化Model和相关的所有属性（字段）
	 */
	public void contruct(){
		if (modelBuilder.init()){
			modelBuilder.buildFieldsProperty();
		}
	}

	/*
	 *在contruct的基础上，设置Property的DefModel 
	 */
	public void buildFieldsInfo(){
		if (!modelBuilder.buildFieldsInfoOk()){
			modelBuilder.buildFieldsInfo();	
			modelBuilder.setBuildFieldsInfoOk(true);
		}
	}
	
	public void buildFields(){
		modelBuilder.buildField();
	}

	/*
	 * 构建Layout顺序：
	 * 1、构建Layout需要的按钮
	 * 2、准备Layout需要的元素，一般是Fields
	 * 3、构建Layout：ListLayout、DetailLayout
	 */
	public void buildLayout(){
		if (!modelBuilder.buildLayoutOk()){
			modelBuilder.buildButtons();
			modelBuilder.prepareLayoutElements();
			modelBuilder.buildLayout();
			modelBuilder.setBuildLayoutOk(true);
		}
	}
	
	public void preBuildMiscData(){
		modelBuilder.preBuildMiscData();
	}
	
	public void buildMiscData(){
		if (!modelBuilder.buildMiscDataOk()){
			modelBuilder.buildMiscData();
			modelBuilder.setBuildMiscDataOk(true);
		}
	}
	
	public void buildModelInitData(){
		modelBuilder.buildModelInitData();
	}
		
}
